﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using eBay.Service.Core.Soap;
using Domain;

namespace eBayBus.Block
{
    public class SiteBlock
    {
        public static Dictionary<string, string> _SiteBlocks = new Dictionary<string, string>();

        public SiteBlock()
        {
            Init();
        }

        private static void Init()
        {
            if (_SiteBlocks.Keys.Count > 0) return;

            _SiteBlocks.Add("AUC(7)_US_STAMP(3487)_NEW", "AUC(7)_US_STAMP(3487)_NEW");
            _SiteBlocks.Add("FIX(30)_US_STAMP(3487)_NEW", "FIX(7)_US_STAMP(3487)_NEW");
            _SiteBlocks.Add("AUC(1)_US_BEADS(164295)_NEW", "AUC(1)_US_BEADS(164295)_NEW");
            _SiteBlocks.Add("AUC(7)_US_BEADS(164295)_NEW", "AUC(7)_US_BEADS(164295)_NEW");
            _SiteBlocks.Add("FIX(30)_US_BEADS(164295)_NEW", "FIX(30)_US_BEADS(164295)_NEW");

            _SiteBlocks.Add("AUC(7)_UK_STAMP(3487)_NEW", "AUC(7)_UK_STAMP(3487)_NEW");
            _SiteBlocks.Add("FIX(30)_UK_STAMP(3487)_NEW", "FIX(7)_UK_STAMP(3487)_NEW");
            _SiteBlocks.Add("AUC(1)_UK_BEADS(92756)_NEW", "AUC(1)_UK_BEADS(92756)_NEW");
            _SiteBlocks.Add("AUC(7)_UK_BEADS(92756)_NEW", "AUC(7)_UK_BEADS(92756)_NEW");
            _SiteBlocks.Add("FIX(30)_UK_BEADS(92756)_NEW", "FIX(30)_UK_BEADS(92756)_NEW");

        }

        public static Dictionary<string, string> GetAll()
        {
            Init();
            return _SiteBlocks;
        }

        public static void SetBlock(string key, ItemType i1, ChaEbayListing cp)
        {
            ChaEbayListingLib listing = new ChaEbayListingLib();
            listing.buyItNow = cp.buyItNow;
            listing.buyRequirementBlock = cp.buyRequirementBlock;
            listing.checkoutBlock = cp.checkoutBlock;
            listing.createDate = DateTime.Now;
            listing.description = cp.description;
            listing.ebayName = cp.ebayName;
            listing.image = cp.image;
            listing.isSandbox = cp.isSandbox;
            listing.listingId = cp.listingId;
            listing.quantity = cp.quantity;
            listing.returnBlock = cp.returnBlock;
            listing.shippingBlock = cp.shippingBlock;
            listing.siteBlock = cp.siteBlock;
            listing.sku = cp.sku;
            listing.startPrice = cp.startPrice;
            listing.status = 0;
            listing.templateBlock = cp.templateBlock;
            listing.title = cp.title;
            listing.updateDate = DateTime.Now;

            SetBlock(key, i1, listing);
        }

        public static void SetBlock(string key, ItemType i1, ChaEbayListingLib cp)
        {

            switch( key)
            {
                case "AUC(7)_US_STAMP(3487)_NEW":

                    #region AUC(7)_US_STAMP(3487)_NEW
                    i1.Site = SiteCodeType.US;
                    i1.ListingType = ListingTypeCodeType.Chinese;
                    i1.PrimaryCategory = new CategoryType();
                    i1.PrimaryCategory.CategoryID = "3487";
                    i1.ListingDuration = "Days_7"; 
                    i1.ListingTypeSpecified = true;
                    i1.Quantity = 1;
                    i1.HitCounter = HitCounterCodeType.BasicStyle;
                    i1.StartPrice = new AmountType();
                    i1.StartPrice.currencyID = CurrencyCodeType.USD;
                    i1.StartPrice.Value = (double)cp.startPrice;
                    i1.Currency = CurrencyCodeType.USD;
                    i1.CurrencySpecified = true;

                    #region Item specifics

                    int attributeSetID, attributeID, valueID;
                    attributeSetID = 2966;
                    attributeID = 10244;
                    valueID = 10425;

                    //Setting  attribute set
                    AttributeSetType[] attributeSetType = new AttributeSetType[1];
                    attributeSetType[0] = new AttributeSetType();
                    attributeSetType[0].attributeSetID = attributeSetID;
                    attributeSetType[0].attributeSetIDSpecified = true;

                    //Setting attribute
                    AttributeType[] attributeType = new AttributeType[1];
                    attributeType[0] = new AttributeType();
                    attributeType[0].attributeID = attributeID;  //Condition Attribute
                    attributeType[0].attributeIDSpecified = true;

                    //Setting Value Type
                    ValType[] valType = new ValType[1];
                    valType[0] = new ValType();
                    valType[0].ValueID = valueID;  //Value for new condition
                    valType[0].ValueIDSpecified = true;
                    valType[0].ValueLiteral = "Unused";

                    attributeType[0].Value = new ValTypeCollection(valType);
                    attributeSetType[0].Attribute = new AttributeTypeCollection(attributeType);

                    i1.AttributeSetArray = new AttributeSetTypeCollection(attributeSetType);

                    #endregion

                    #endregion

                    break;

                case "FIX(30)_US_STAMP(3487)_NEW":

                    #region FIX(30)_US_STAMP(3487)_NEW
                    i1.Site = SiteCodeType.US;
                    i1.PrimaryCategory = new CategoryType();
                    i1.PrimaryCategory.CategoryID = "3487";
                    i1.ListingDuration = "Days_30";
                    i1.ListingType = ListingTypeCodeType.FixedPriceItem;
                    i1.ListingTypeSpecified = true;
                    i1.Quantity = cp.quantity;
                    i1.StartPrice = new AmountType();
                    i1.StartPrice.currencyID = CurrencyCodeType.USD;
                    i1.StartPrice.Value = Convert.ToDouble( cp.buyItNow );
                    i1.HitCounter = HitCounterCodeType.BasicStyle;
                    i1.Currency = CurrencyCodeType.USD;
                    i1.CurrencySpecified = true;


                    #region Item specifics


                    attributeSetID = 2966;
                    attributeID = 10244;
                    valueID = 10425;

                    //Setting  attribute set
                    attributeSetType = new AttributeSetType[1];
                    attributeSetType[0] = new AttributeSetType();
                    attributeSetType[0].attributeSetID = attributeSetID;
                    attributeSetType[0].attributeSetIDSpecified = true;

                    //Setting attribute
                    attributeType = new AttributeType[1];
                    attributeType[0] = new AttributeType();
                    attributeType[0].attributeID = attributeID;  //Condition Attribute
                    attributeType[0].attributeIDSpecified = true;

                    //Setting Value Type
                    valType = new ValType[1];
                    valType[0] = new ValType();
                    valType[0].ValueID = valueID;  //Value for new condition
                    valType[0].ValueIDSpecified = true;
                    valType[0].ValueLiteral = "Unused";

                    attributeType[0].Value = new ValTypeCollection(valType);
                    attributeSetType[0].Attribute = new AttributeTypeCollection(attributeType);

                    i1.AttributeSetArray = new AttributeSetTypeCollection(attributeSetType);

                    #endregion

                    #endregion

                    break;
                case "AUC(7)_UK_STAMP(3487)_NEW":

                    #region AUC(7)_UK_STAMP(3487)_NEW
                    i1.Site = SiteCodeType.UK;
                    i1.PrimaryCategory = new CategoryType();
                    i1.PrimaryCategory.CategoryID = "3487";
                    i1.ListingDuration = "Days_7";
                    i1.ListingType = ListingTypeCodeType.Chinese;
                    i1.ListingTypeSpecified = true;
                    i1.StartPrice = new AmountType();
                    i1.StartPrice.currencyID = CurrencyCodeType.GBP;
                    i1.StartPrice.Value = Convert.ToDouble(cp.startPrice);
                    i1.Quantity = 1;
                    i1.HitCounter = HitCounterCodeType.BasicStyle;
                    i1.Currency = CurrencyCodeType.GBP;
                    i1.CurrencySpecified = true;


                    #endregion

                    break;

                case "FIX(30)_UK_STAMP(3487)_NEW":

                    #region FIX(30)_UK_STAMP(3487)_NEW
                    i1.Site = SiteCodeType.UK;
                    i1.PrimaryCategory = new CategoryType();
                    i1.PrimaryCategory.CategoryID = "3487";
                    i1.ListingDuration = "Days_30";
                    i1.ListingType = ListingTypeCodeType.FixedPriceItem;
                    i1.ListingTypeSpecified = true;
                    i1.Quantity = cp.quantity;
                    i1.StartPrice = new AmountType();
                    i1.StartPrice.currencyID = CurrencyCodeType.GBP;
                    i1.StartPrice.Value = Convert.ToDouble(cp.buyItNow);
                    i1.HitCounter = HitCounterCodeType.BasicStyle;
                    i1.Currency = CurrencyCodeType.GBP;
                    i1.CurrencySpecified = true;



                    #endregion

                    break;

                case "AUC(7)_US_BEADS(164295)_NEW":

                    #region AUC(7)_US_BEADS(164295)_NEW
                    i1.Site = SiteCodeType.US;
                    i1.PrimaryCategory = new CategoryType();
                    i1.PrimaryCategory.CategoryID = "164295";
                    i1.ListingDuration = "Days_7";
                    i1.ListingType = ListingTypeCodeType.Chinese;
                    i1.ListingTypeSpecified = true;
                    i1.Quantity = 1;
                    i1.HitCounter = HitCounterCodeType.BasicStyle;
                    i1.StartPrice = new AmountType();
                    i1.StartPrice.currencyID = CurrencyCodeType.USD;
                    i1.StartPrice.Value = (double)cp.startPrice;
                    i1.Currency = CurrencyCodeType.USD;
                    i1.CurrencySpecified = true;


                    i1.ConditionID = 1500;
                    i1.ConditionIDSpecified = true;





                    #endregion

                    break;
                case "AUC(1)_US_BEADS(164295)_NEW":

                    #region AUC(1)_US_BEADS(164295)_NEW
                    i1.Site = SiteCodeType.US;
                    i1.PrimaryCategory = new CategoryType();
                    i1.PrimaryCategory.CategoryID = "164295";
                    i1.ListingDuration = "Days_1";
                    i1.ListingType = ListingTypeCodeType.Chinese;
                    i1.ListingTypeSpecified = true;
                    i1.Quantity = 1;
                    i1.HitCounter = HitCounterCodeType.BasicStyle;
                    i1.StartPrice = new AmountType();
                    i1.StartPrice.currencyID = CurrencyCodeType.USD;
                    i1.StartPrice.Value = (double)cp.startPrice;
                    i1.Currency = CurrencyCodeType.USD;
                    i1.CurrencySpecified = true;


                    i1.ConditionID = 1500;
                    i1.ConditionIDSpecified = true;





                    #endregion

                    break;
                case "FIX(30)_US_BEADS(164295)_NEW":

                    #region FIX(30)_US_BEADS(164295)_NEW
                    i1.Site = SiteCodeType.US;
                    i1.ListingType = ListingTypeCodeType.FixedPriceItem;
                    i1.PrimaryCategory = new CategoryType();
                    i1.PrimaryCategory.CategoryID = "164295";
                    i1.ListingDuration = "Days_30";
                    i1.ListingTypeSpecified = true;
                    i1.Quantity = 5;
                    i1.HitCounter = HitCounterCodeType.BasicStyle;
                    i1.StartPrice = new AmountType();
                    i1.StartPrice.currencyID = CurrencyCodeType.USD;
                    i1.StartPrice.Value = Convert.ToDouble(cp.buyItNow);
                    i1.Currency = CurrencyCodeType.USD;
                    i1.CurrencySpecified = true;


                    i1.ConditionID = 1500;
                    i1.ConditionIDSpecified = true;





                    #endregion

                    break;
                case "AUC(7)_UK_BEADS(92756)_NEW":

                    #region AUC(7)_UK_BEADS(92756)_NEW
                    i1.Site = SiteCodeType.UK;
                    i1.PrimaryCategory = new CategoryType();
                    i1.PrimaryCategory.CategoryID = "92756";
                    i1.ListingDuration = "Days_7";
                    i1.ListingType = ListingTypeCodeType.Chinese;
                    i1.ListingTypeSpecified = true;
                    i1.Quantity = 1;
                    i1.HitCounter = HitCounterCodeType.BasicStyle;
                    i1.StartPrice = new AmountType();
                    i1.StartPrice.currencyID = CurrencyCodeType.GBP;
                    i1.StartPrice.Value = (double)cp.startPrice;
                    i1.Currency = CurrencyCodeType.GBP;
                    i1.CurrencySpecified = true;


                    i1.ConditionID = 1500;
                    i1.ConditionIDSpecified = true;





                    #endregion

                    break;
                case "AUC(1)_UK_BEADS(92756)_NEW":

                    #region AUC(1)_UK_BEADS(92756)_NEW
                    i1.Site = SiteCodeType.UK;
                    i1.PrimaryCategory = new CategoryType();
                    i1.PrimaryCategory.CategoryID = "92756";
                    i1.ListingDuration = "Days_1";
                    i1.ListingType = ListingTypeCodeType.Chinese;
                    i1.ListingTypeSpecified = true;
                    i1.Quantity = 1;
                    i1.HitCounter = HitCounterCodeType.BasicStyle;
                    i1.StartPrice = new AmountType();
                    i1.StartPrice.currencyID = CurrencyCodeType.GBP;
                    i1.StartPrice.Value = (double)cp.startPrice;
                    i1.Currency = CurrencyCodeType.GBP;
                    i1.CurrencySpecified = true;

                    i1.ConditionID = 1500;
                    i1.ConditionIDSpecified = true;

                    #endregion

                    break;
                case "FIX(30)_UK_BEADS(92756)_NEW":

                    #region FIX(30)_UK_BEADS(92756)_NEW
                    i1.Site = SiteCodeType.UK;
                    i1.ListingType = ListingTypeCodeType.FixedPriceItem;
                    i1.PrimaryCategory = new CategoryType();
                    i1.PrimaryCategory.CategoryID = "92756";
                    i1.ListingDuration = "Days_30";
                    i1.ListingTypeSpecified = true;
                    i1.Quantity = 5;
                    i1.HitCounter = HitCounterCodeType.BasicStyle;
                    i1.StartPrice = new AmountType();
                    i1.StartPrice.currencyID = CurrencyCodeType.GBP;
                    i1.StartPrice.Value = (double)cp.buyItNow;
                    i1.Currency = CurrencyCodeType.GBP;
                    i1.CurrencySpecified = true;


                    i1.ConditionID = 1500;
                    i1.ConditionIDSpecified = true;





                    #endregion

                    break;
                default:
                    break;
            }

        }

    }
}
